# -*- coding: utf-8 -*-
# @Time    : 2020/8/17 17:07
# @Author  : Leo
# @FileName: handlers.py
# @Software: PyCharm
import tornado.web
from modules.user.wechat import wechat_request



class Wecahtlistener(tornado.web.RequestHandler):
    def get(self):
        '''
        开发者设置
        '''
        req = self.request
        self.write(req.arguments['echostr'][0])


        ## 对用户消息响应

    def post(self):
        '''
        接收微信事件推送
        '''

        self.write('success')  # 直接恢复空串 告诉微信平台已处理请求
        data = wechat_request.XMLHandler().xmlToDict(self.request.body)
        wechat_request.WechatRequest.response_wechat_event(data)


